import requests
import json

headers = {'Content-Type': 'application/json'}
payload = {"username":"admin","password":"123456"}
r = requests.post("http://127.0.0.1:5000/devops/api/v1.0/login",headers=headers,data=json.dumps(payload))
data=json.loads(r.text)
print(data)
headers['token']=data['token']
print(headers)
sendmail={'subject':'test','sendmail':'9429042@qq.com','body':'邮件推送'}
r = requests.post("http://127.0.0.1:5000/devops/api/v1.0/sendmail",headers=headers,data=json.dumps(sendmail))
print(r.text)
